<template>
  <el-container>
    <el-aside :width="isCollapse?'64px':'200px'">
      <el-menu
          :router="true"
          :collapse="isCollapse"
          background-color="#20222A"
          text-color="#fff"
          :default-active="$route.path"
          :open="1"
          active-text-color="#ffd04b">
        <div id="title">后台管理系统</div>
        <el-menu-item index="/home/main">
          <i class="el-icon-s-home"></i>
          <span slot="title">主页</span>
        </el-menu-item>
        <el-submenu index="1">
          <template slot="title">
            <i class="el-icon-s-shop"></i>
            <span>填报管理</span>
          </template>
          <el-menu-item index="/home/contract">
            <i class="el-icon-s-order"></i>
            <span>填报列表</span>
          </el-menu-item>
          <!-- <el-menu-item index="/home/purchasing-list">
            <i class="el-icon-s-order"></i>
            <span>采购清单管理</span>
          </el-menu-item>
          <el-menu-item index="/home/salesman">
            <i class="el-icon-user-solid"></i>
            <span>销售员管理</span>
          </el-menu-item> -->
          
        </el-submenu>
        <el-submenu index="2">
          <template slot="title">
            <i class="el-icon-box"></i>
            <span>报表导出</span>
          </template>
          <el-menu-item index="/home/goods">
            <i class="el-icon-help"></i>
            <span>导出</span>
          </el-menu-item>
          <!-- <el-menu-item index="/home/input-list">
            <i class="el-icon-back"></i>
            <span>进货单管理</span>
          </el-menu-item>
          <el-menu-item index="/home/dispatch-list">
            <i class="el-icon-right"></i>
            <span>发货单管理</span>
          </el-menu-item> -->
        </el-submenu>
        <el-submenu index="3">
          <template slot="title">
            <i class="el-icon-s-home"></i>
            <span>用户管理</span>
          </template>
          <el-menu-item index="/home/user">
            <i class="el-icon-s-data"></i>
            <span>管理员列表</span>
          </el-menu-item>
          <el-menu-item index="/home/client">
            <i class="el-icon-s-custom"></i>
            <span>用户列表</span>
          </el-menu-item>
        </el-submenu>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header height="80px">
        <div id="headerTop">
          <div style="display: inline-block; position: absolute; left: 10px"><i class="el-icon-s-fold" @click="closeMenu"></i></div>
          <div style="display: inline-block; position: absolute; right: 15px;top:10px">
            <el-dropdown>
              <span class="el-dropdown-link"  style="cursor: pointer">
                {{this.$store.state.admin.username}}<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown" >
                <el-dropdown-item><span @click="logout">退出</span></el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </div>
      </el-header>
      <el-main style="overflow: hidden">
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import {logout} from '@/api/user'
import {getUserInfo} from '@/api/common'
export default {
    name: "Home",
    data(){
      return {
        isCollapse: false,   //是否折叠菜单
        authority: '', //权限字符串
        user: {}
      }
    },
    methods: {
      //折叠菜单方法
      closeMenu(){
        this.isCollapse = !this.isCollapse;
      },
      // 登出
      logout(){
        logout().then(res => {
          this.$router.push('/login')
        })
      }
    }
    ,mounted() {
      
    }
    ,created(){
      // getUserInfo().then(res => {
      //   this.user = res.data.userInfo
      //   this.authority = res.data.userInfo.authorities[0].authority
      //   console.log(this.authority);
      // })
    }
  }
</script>

<style scoped>

  #title{
    height: 39px;
    line-height: 39px;
    font-size: 16px;
    font-weight: normal;
    color: rgba(255,255,255,0.6);
    text-align: center;
    border-bottom: 1px rgba(255,255,255,0.1) solid;
  }
  #headerTop{
    position: relative;
    height: 39px;
    border-bottom: 1px rgba(102,102,102,0.1) solid;
  }
  #headerBottom{
    height: 40px;
  }
  .el-container{
    height: 100vh;
  }
  .el-aside{
    background-color: #20222A;
  }
  .el-header{
    background-color: rgba(255,255,255,1);
    margin: 0;
    padding: 0;
    box-shadow: 1px 1px 1px rgba(102,102,102,0.8);
  }
  .el-menu{
    border: 0;
  }
  .el-icon-s-fold{
    font-size: 28px;
    margin: 8px 0px 0px 10px;
  }
</style>
